﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProgNetComponents.Design.Editors;
using ProgNetComponents.Utils;

namespace ProgNetComponents.Validation.Design
{
    /// <summary>
    /// IDataValidationRuleColumnNameTabEditor
    /// </summary>
    public class IDataValidationRuleColumnNameTabEditor : ColumnNameTabEditor
    {
        /// <summary>
        /// Gets the ListBox items.
        /// </summary>
        /// <returns></returns>
        protected override Dictionary<string, string> GetListBoxItems()
        {
            if (context.Instance is IDataValidationRule)
            {
                object dataSource = ((IDataValidationRule)context.Instance).DataSource;
                var columns = DesignUtils.GetColumns(dataSource, null, context, servideProvider);
                Dictionary<string, string> l = new Dictionary<string, string>();
                foreach (string col in columns)
                {
                    l.Add(col, col);
                }
                return l;
            }
            else
            {
                return base.GetListBoxItems();
            }
        }
    }
}
